package chapter05

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/1 20:24
  * @history:
  *          1.2019/1/1 created by chuhaitao
  */
object FunctionDemo {

  def main(args: Array[String]): Unit = {
    var dog = new Dog
    println(dog.sum(1, 2))
    //方法转成函数
    var f1 = dog.sum _
    println(f1(1, 4))
    //自定义函数
    var f2 = (n3:Int, n2:Int) => {
     n2+n3
    }
    println(f2(3, 5))
  }

}


class Dog {
  def sum(n1: Int, n2: Int): Int = {
    n1 + n2
  }
}
